package com.zjcloud.jwgl.domain;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zjcloud.common.annotation.Excel;
import com.zjcloud.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import javax.validation.constraints.*;
import java.util.Date;
import java.math.BigDecimal;

/**
 * 约束违反记录对象 ac_constraint_violation
 * 
 * @author zjcloud
 * @date 2024-01-01
 */
public class AcConstraintViolation extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    private Long id;

    /** 排课记录ID */
    @Excel(name = "排课记录ID")
    private Long scheduleId;

    /** 约束条件ID */
    @Excel(name = "约束条件ID")
    private Long constraintId;

    /** 违反类型(HARD-硬约束违反 SOFT-软约束违反) */
    @Excel(name = "违反类型", readConverterExp = "HARD=硬约束违反,SOFT=软约束违反")
    private String violationType;

    /** 违反级别(1-严重 2-一般 3-轻微) */
    @Excel(name = "违反级别")
    private Integer violationLevel;

    /** 违反分数 */
    @Excel(name = "违反分数")
    private BigDecimal violationScore;

    /** 违反描述 */
    @Excel(name = "违反描述")
    private String violationDesc;

    /** 解决方案 */
    @Excel(name = "解决方案")
    private String solution;

    /** 是否已解决(0-否 1-是) */
    @Excel(name = "是否已解决", readConverterExp = "0=否,1=是")
    private String resolved;

    /** 解决时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "解决时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date resolvedTime;

    /** 解决人 */
    @Excel(name = "解决人")
    private String resolvedBy;

    /** 关联的排课记录（非数据库字段） */
    private AcSchedule schedule;

    /** 关联的约束条件（非数据库字段） */
    private AcScheduleConstraint constraint;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setScheduleId(Long scheduleId) 
    {
        this.scheduleId = scheduleId;
    }

    public Long getScheduleId() 
    {
        return scheduleId;
    }
    public void setConstraintId(Long constraintId) 
    {
        this.constraintId = constraintId;
    }

    public Long getConstraintId() 
    {
        return constraintId;
    }
    public void setViolationType(String violationType) 
    {
        this.violationType = violationType;
    }

    public String getViolationType() 
    {
        return violationType;
    }
    public void setViolationLevel(Integer violationLevel) 
    {
        this.violationLevel = violationLevel;
    }

    public Integer getViolationLevel() 
    {
        return violationLevel;
    }
    public void setViolationScore(BigDecimal violationScore) 
    {
        this.violationScore = violationScore;
    }

    public BigDecimal getViolationScore() 
    {
        return violationScore;
    }
    public void setViolationDesc(String violationDesc) 
    {
        this.violationDesc = violationDesc;
    }

    public String getViolationDesc() 
    {
        return violationDesc;
    }
    public void setSolution(String solution) 
    {
        this.solution = solution;
    }

    public String getSolution() 
    {
        return solution;
    }
    public void setResolved(String resolved) 
    {
        this.resolved = resolved;
    }

    public String getResolved() 
    {
        return resolved;
    }
    public void setResolvedTime(Date resolvedTime) 
    {
        this.resolvedTime = resolvedTime;
    }

    public Date getResolvedTime() 
    {
        return resolvedTime;
    }
    public void setResolvedBy(String resolvedBy) 
    {
        this.resolvedBy = resolvedBy;
    }

    public String getResolvedBy() 
    {
        return resolvedBy;
    }

    public AcSchedule getSchedule() 
    {
        return schedule;
    }

    public void setSchedule(AcSchedule schedule) 
    {
        this.schedule = schedule;
    }

    public AcScheduleConstraint getConstraint() 
    {
        return constraint;
    }

    public void setConstraint(AcScheduleConstraint constraint) 
    {
        this.constraint = constraint;
    }

    /**
     * 判断是否已解决
     */
    public boolean isResolved() {
        return "1".equals(this.resolved);
    }

    /**
     * 判断是否为严重违反
     */
    public boolean isSevereViolation() {
        return violationLevel != null && violationLevel == 1;
    }

    /**
     * 判断是否为硬约束违反
     */
    public boolean isHardViolation() {
        return "HARD".equals(this.violationType);
    }

    /**
     * 判断是否为软约束违反
     */
    public boolean isSoftViolation() {
        return "SOFT".equals(this.violationType);
    }

    /**
     * 获取违反级别描述
     */
    public String getViolationLevelDesc() {
        if (violationLevel == null) {
            return "未知";
        }
        switch (violationLevel) {
            case 1:
                return "严重";
            case 2:
                return "一般";
            case 3:
                return "轻微";
            default:
                return "未知";
        }
    }

    /**
     * 获取违反类型描述
     */
    public String getViolationTypeDesc() {
        if (violationType == null) {
            return "未知";
        }
        switch (violationType) {
            case "HARD":
                return "硬约束违反";
            case "SOFT":
                return "软约束违反";
            default:
                return "未知";
        }
    }

    /**
     * 获取约束名称
     */
    public String getConstraintName() {
        return constraint != null ? constraint.getName() : "";
    }

    /**
     * 获取违反分数显示值
     */
    public String getViolationScoreDisplay() {
        return violationScore != null ? violationScore.toString() : "0";
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("scheduleId", getScheduleId())
            .append("constraintId", getConstraintId())
            .append("violationType", getViolationType())
            .append("violationLevel", getViolationLevel())
            .append("violationScore", getViolationScore())
            .append("violationDesc", getViolationDesc())
            .append("solution", getSolution())
            .append("resolved", getResolved())
            .append("resolvedTime", getResolvedTime())
            .append("resolvedBy", getResolvedBy())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .append("remark", getRemark())
            .toString();
    }
}